﻿using System;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UIElements;

public class CardViewSystem : Singleton<CardViewSystem>
{
    [field: SerializeField] public GameObject CardViewSlot { get; set; }
    [field: SerializeField] private CardView cardView; // 当前悬停卡牌实例

    public bool PlayerIsDragging { get; set; } = false;

    public bool PlayerCanInteract()
    {
        return !ActionSystem.Instance.IsPerforming;
    }

    public bool PlayerCanHover()
    {
        return !PlayerIsDragging;
    }

    public void Show(Card card, Vector3 position)
    {
        // ========== 逻辑部分 ==========
        cardView.gameObject.SetActive(true);
        cardView.Setup(card);

        // 初始状态
        Transform t = cardView.transform;
        t.position = new Vector3(position.x, -3f, 0f); // 起始位置
        t.localScale = Vector3.one * 0.8f; // 初始缩小

        // ========== 动画部分 ==========
        t.DOKill(); // 避免旧动画叠加
        Sequence seq = DOTween.Sequence();
        seq.Append(t.DOMove(new Vector3(position.x, -2f, 0f), 0.1f).SetEase(Ease.OutCubic))
           .Join(t.DOScale(1.3f, 0.1f).SetEase(Ease.OutQuad));
    }

    public void Hide()
    {

        cardView.gameObject.SetActive(false);

    }

    /// <summary>
    /// 打印位置、激活状态和可见性
    /// </summary>
}
